package priv.pfz.raft.verify.cmd;

import lombok.extern.slf4j.Slf4j;
import priv.pfz.raft.network.dto.WriteReq;
import priv.pfz.raft.network.dto.WriteResp;
import priv.pfz.raft.peer.ClusterHolder;

import java.util.List;

/**
 * @author pengfangzhou
 * @date 2022/2/7 23:55
 */
@Slf4j
public class WriteCmd implements CmdExecutor {
    @Override
    public void execute(List<String> params) {
        String peer = params.get(0);
        Integer value = Integer.parseInt(params.get(1));
        WriteReq req = new WriteReq();
        req.setValue(value);
        WriteResp resp = ClusterHolder.peerMap.get(peer).handleWrite(req);
        log.info("{}写:{}", peer, resp.getMsg());
    }
}
